/*
 * @Author: zhangshu
 * @email: shiliang.zhang@tuya.com
 * @LastEditors: Please set LastEditors
 * @file name: app_led.h
 * @Description: 
 * @Copyright: HANGZHOU TUYA INFORMATION TECHNOLOGY CO.,LTD
 * @Company: http://www.tuya.com
 * @Date: 2022-02-08
 * @LastEditTime: 2022-02-08
 */
#ifndef __APP_LED_H__
#define __APP_LED_H__

#ifdef __cplusplus
extern "C" {
#endif

#include "tal_mf_test.h"

#include "app_common.h"

//led blink type
typedef enum {
    LED_INDICATE_TYPE_NONE,
    LED_INDICATE_TYPE_ONCE,
    LED_INDICATE_TYPE_SOLID,
}LED_INDICATE_TYPE_E;

//led blink type
typedef enum {
    LED_BLINK_TYPE_NONE,           //blink none, default type
    LED_BLINK_TYPE_POWER_ON,       //blink when power on
    LED_BLINK_TYPE_START_JOIN,     //blink when start join network
    LED_BLINK_TYPE_JOIN_SUCCESS,   //blink when join success
    LED_BLINK_TYPE_BUTTON_DOWN,    //solid when button down
    LED_BLINK_TYEP_ALARM,          //blink when door open
    LED_BLINK_TYEP_TAMPER,         //blink when tamper trigger
    LED_BLINK_TYPE_IDENTIFY,       //blink when identify
    LED_BLINK_TYPE_MF_TEST,
}LED_BLINK_TYPE_E;

//oem led struct
typedef struct {
    BOOL_T enabled;
    BOOL_T driver_flag;
    TUYA_GPIO_NUM_E pin_num;
} OEM_LED_INFO_T;

//led info
typedef struct {
    OEM_LED_INFO_T status_led;
    OEM_LED_INFO_T net_led;
    LED_INDICATE_TYPE_E alarm_type;
    LED_INDICATE_TYPE_E tamper_type;
    LED_INDICATE_TYPE_E trouble_type;
} APP_LED_INFO_T;

/**
 * @description: led init
 * @param[in] info: led info
 * @return: OPERATE_RET, success when OPRT_OK, or else
 */
OPERATE_RET app_led_oem_init(APP_LED_INFO_T *info);

/**
 * @description: power on solid indicate
 * @param[in] none
 * @return: none
 */
VOID_T dev_power_on_indicate(VOID_T);

/**
 * @description: device start join led indicate
 * @param[in] none
 * @return: none
 */
VOID_T dev_start_join_indicate(BOOL_T indicate);

/**
 * @description: device join network success led indicate
 * @param[in] none
 * @return: none
 */
VOID_T dev_join_success_indicate(VOID_T);

/**
 * @description: device alarm indicate
 * @param[in] alarm: TRUE when alarm or not
 * @return: none
 */
VOID_T dev_alarm_indicate(BOOL_T alarm);

/**
 * @description: device tamper indicate
 * @param[in] tamper: TRUE when tamper or not
 * @return: none
 */
VOID_T dev_tamper_indicate(BOOL_T tamper);

/**
 * @description: device trouble indicate
 * @param[in] tamper: TRUE when tamper or not
 * @return: none
 */
VOID_T dev_trouble_indicate(VOID_T);

/**
 * @description: button press indicate
 * @param[in] none
 * @return: none
 */
VOID_T button_press_on_indicate(VOID_T);

/**
 * @description: button release indicate
 * @param[in] none
 * @return: none
 */
VOID_T button_release_off_indicate(VOID_T);

/**
 * @description: identify indicate
 * @param[in] time_ms: identify time in ms
 * @return: none
 */
VOID_T identify_indicate(UINT32_T time_ms);

/**
 * @description: manufacture test blink
 * @param[in] cmd: manufacture command, refer to TUYA_MF_TEST_CMD_T
 * @return: none
 */
VOID_T mf_test_blink(TUYA_MF_TEST_CMD_T cmd);

/**
 * @description: set alarm led on off state
 * @param[in] state: on off state
 * @return: none
 */
VOID_T set_alarm_led_on_off(BOOL_T alarm, UINT8_T state);

/**
 * @description: led blink complete callback
 * @param[in] type: blink type, refer to LED_BLINK_TYPE_E
 * @return: none
 */
VOID_T led_blink_complete_callback(LED_BLINK_TYPE_E type);

#ifdef __cplusplus
}
#endif

#endif

